<!-- 废弃不用-->
<template>
    <Layout>
        <Form ref="form1" :model="form1" :label-width="120">
            <Row class="query-form" style="padding-top: 15px"  v-show="!switchFlag">
                <Col span="8">
                    <FormItem label="人员名称：">
                        <Input type="text" v-model="form1.driverName"/>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="作业类型：">
                        <Input class="query-form-el" type="text" v-model="form1.workType" ></Input>
                    </FormItem>
                </Col>
                <Col span="8">
                    <Button @click="switchQuery(true)" class="ivu-btn-switch" type="text"  >展开∨</Button>
                    <Button @click="reset" class="ivu-btn-reset" style="margin-left: 2px">重置</Button>
                    <Button class="ivu-btn-query" icon="md-search" @click="query()">查询</Button>
                </Col>
            </Row>
            <Row  v-show="switchFlag" class="query-form" style="padding-top: 15px">
                <Col span="8">
                    <FormItem label="人员名称：">
                        <Input type="text" v-model="form1.driverName"/>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="作业类型：" >
                        <Input class="query-form-el" type="text" v-model="form1.workType" ></Input>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="发证日期：">
                        <Date-picker type="daterange" style="width: 95%" v-model="certificateDate"/>
                    </FormItem>
                </Col>
            </Row>
            <Row  v-show="switchFlag" class="query-form" style="padding-top: 15px">
                <Col span="8">
                    <FormItem label="复审日期：">
                        <Date-picker type="daterange" style="width: 95%" v-model="reviewDate"/>
                    </FormItem>
                </Col>
            </Row>
            <Row v-show="switchFlag" class="query-form">
                <Col span="24">
                    <Button @click="switchQuery(false)" class="ivu-btn-switch" type="text"  >收起∧</Button>
                    <Button @click="reset" class="ivu-btn-reset"   >重置</Button>
                    <Button   class="ivu-btn-query"   icon="md-search" @click="query">查询</Button>
                </Col>
            </Row>
        </Form>
        <Table ref='table' :height="tableHeight" :loading="loading" size="small" class="table" no-data-text="没有查询到相关数据!"
               highlight-row stripe border :columns="columns1" width="100%" :data="dataTable" :row-class-name="rowClassName">
        </Table>
        <Row style="margin-right:10px;">
            <Col span="24">
                <Page :total="pagedata.total" :page-size="pagedata.pageSize" @on-change="pageChange"
                      style="float: right" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray"
                      show-total show-sizer show-elevator/>
            </Col>
        </Row>

        <Modal :transfer=false v-model="model1" :width=981  :title="add?'特种设备人员新增':'特种设备人员修改'"
               @on-cancel="onCancel">
            <div>
                <Form style="margin-left: 10px" ref='InputData' :model="InputData" :rules="ruleCustom"
                      label-position="top">
                    <Row style="line-height: 28px;">

                        <Col span='5' >
                            <FormItem label='姓名：' prop="driverName">
                                <Input v-model="InputData.driverName"/>
                            </FormItem>
                        </Col>

                        <Col span='5' offset="1">
                            <FormItem label='性别：' prop="brand">
                                <Select class="query-form-el" filterable v-model="InputData.brand"  >
                                    <Option v-for="item in brandList" :value="item.value" :key="item.value">{{ item.name }}</Option>
                                </Select>
                            </FormItem>
                        </Col>
                        <Col span='5' offset="1">
                            <FormItem label='所属部门：' prop="belongOrgId">
                                <Input v-model="InputData.belongOrgId"/>
                            </FormItem>
                        </Col>
                        <Col span='5' offset="1">
                            <FormItem label='岗位：' prop="station">
                                <Input v-model="InputData.station" />
                            </FormItem>
                        </Col>
                        <Col span='5' >
                            <FormItem label='身份证：' prop="colour">
                                <Input  v-model="InputData.colour" />
                            </FormItem>
                        </Col>

                        <Col span='5' offset="1">
                            <FormItem label='作业类型：' prop="workType">
                                <Input v-model="InputData.workType" />
                            </FormItem>
                        </Col>



                        <Col span='5' offset="1">
                            <FormItem label='证书编号：' prop="certificateNo">
                                <Input v-model="InputData.certificateNo" />
                            </FormItem>
                        </Col>

                        <Col span='5' offset="1" >
                            <FormItem label='发证机关：' prop="certificationAuthority">
                                <Input v-model="InputData.certificationAuthority" />
                            </FormItem>
                        </Col>
                        <Col span='5' >
                            <FormItem label='发证日期：' prop="certificateDate">
                                <Date-picker type="date" placeholder="选择日期" v-model="InputData.certificateDate"></Date-picker>
                            </FormItem>
                        </Col>


                        <Col span='5'offset="1" >
                            <FormItem label='有效期：' prop="validityTerm">
                                <Date-picker type="date" placeholder="选择日期" v-model="InputData.validityTerm"></Date-picker>
                            </FormItem>
                        </Col>



                        <Col span='5' offset="1">
                            <FormItem label='复审日期：' prop="reviewDate">
                                <Date-picker type="date" placeholder="选择日期" v-model="InputData.reviewDate"></Date-picker>
                            </FormItem>
                        </Col>
                        <Col span='5' offset="1">
                            <FormItem label='复审情况：' prop="review">
                                <Input v-model="InputData.review" />
                            </FormItem>
                        </Col>

                        <Col span="8" class="query-form">
                            <Button class="ivu-btn-add" icon="md-add" @click="addItemInfo()">新增项目</Button>
                        </Col>
                        <Col span="23" style="margin-top: 10px;margin-bottom: 10px">
                            <Table height="300"  :loading="loading" size="small" class="table" no-data-text="没有查询到相关数据!"
                                   highlight-row stripe border :columns="columns3" width="100%" :data="evaluateItem">
                            </Table>
                        </Col>
                    </Row>
                </Form>
            </div>
            <div slot="footer">
                <Button class='ivu-btn-save' :loading="buttonLoading" @click="submit('InputData')">确定</Button>
                <Button class='ivu-btn-cancel' @click="onCancel">取消</Button>
            </div>
        </Modal>

        <Modal :transfer=false v-model="model3" :width=1100  title="特种人员详情"
               @on-cancel="onCancel">
            <Form style="margin-left: 10px" :model="InputData" label-position="top">
                <Row style="line-height: 42px;">

                    <Col span='5' >
                        <span>姓名：{{InputData.driverName}}</span>
                    </Col>
                    <Col span='5' offset="1">
                        <span>性别：{{InputData.brand === '0'? '男':'女'}}</span>
                    </Col>
                    <Col span='5'  offset="1" >
                        <span>所属部门：{{InputData.belongOrgId}}</span>
                    </Col>
                    <Col span='5'  offset="1">
                        <span>岗位：{{InputData.station}}</span>
                    </Col>
                </Row>
                <Row class="detail-background-clor" style="line-height: 42px;">
                    <Col span='5' >
                        <span>身份证：{{InputData.colour}}</span>
                    </Col>

                    <Col span='5' offset="1">
                        <span>作业类型：{{InputData.workType}}</span>
                    </Col>
                    <Col span='5' offset="1">
                        <span>证书编号：{{InputData.certificateNo}}</span>
                    </Col>
                    <Col span='5' offset="1">
                        <span>发证机关：{{InputData.certificationAuthority}}</span>
                    </Col>
                </Row>
                <Row  style="line-height: 42px;">
                    <Col span='5'>
                        <span>发证日期：{{certificateDate1}}</span>
                    </Col>
                    <Col span='5'  offset="1">
                        <span>有效期：{{validityTerm}}</span>
                    </Col>
                    <Col span='5' offset="1">
                        <span>复审日期：{{reviewDate1}}</span>
                    </Col>
                    <Col span='5' offset="1">
                        <span>复审情况：{{InputData.review}}</span>
                    </Col>
                    
                </Row>
                <Row style="line-height: 42px;">
                    <Col span='23' style="margin-top: 10px;margin-bottom: 10px">
                        <Table height="300" class="table"  :loading="loading" size="small" no-data-text="没有查询到相关数据!"
                               highlight-row stripe border :columns="columns10" width="100%" :data="evaluateItem">
                        </Table>
                    </Col>
                </Row>
            </Form>
            <div slot="footer">
                <Button class='ivu-btn-save' @click="onCancel">关闭</Button>
            </div>
        </Modal>
        <Modal :transfer=false v-model="model4" :width=700  :title="addItem?'项目新增':'项目修改'"
               @on-cancel="model4=false;InputItemData={}">
            <div>
                <Form ref='InputItemData' :model="InputItemData" :rules="ruleCustom1" label-position="top">
                    <Row style="line-height: 42px;">
                        <Col span='7'>
                            <FormItem label='项目名称：' prop="projectName">
                                <Input v-model="InputItemData.projectName" />
                            </FormItem>
                        </Col>
                        <Col span='7' offset="1">
                            <FormItem label='批准日期：' prop="approvalDate">
                                <Date-picker type="date" style="width: 100%" v-model="InputItemData.approvalDate"/>
                            </FormItem>
                        </Col>
                        <Col span='7' offset="1">
                            <FormItem label='有效日期：' prop="effectiveDate">
                                <Date-picker type="date" style="width: 100%" v-model="InputItemData.effectiveDate"/>
                            </FormItem>
                        </Col>
                        <Col span='23'>
                            <FormItem label='备注：' prop="remarks">
                                <Input v-model="InputItemData.remarks" type="textarea"
                                       :autosize="{minRows:2,maxRows:5}"/>
                            </FormItem>
                        </Col>

                    </Row>
                </Form>
            </div>
            <div slot="footer">
                <Button class='ivu-btn-save' :loading="buttonLoading" @click="submitItem('InputItemData')">确定</Button>
                <Button class='ivu-btn-cancel' @click="model4=false;InputItemData={}">取消</Button>
            </div>
        </Modal>

        <Modal :transfer=false v-model="model5"  :width=600 :title="'项目详情'"
               @on-cancel="model5=false" >
            <Form class="modal-view-detail" :model="InputItemData" label-position="top" >
                <Row style="line-height: 42px;">
                    <Col span='7'>
                        <span>项目名称：{{InputItemData.projectName}}</span>
                    </Col>
                    <Col span='7' offset="1">
                        <span>批准日期：{{approvalDate}}</span>
                    </Col>
                    <Col span='7' offset="1">
                        <span>有效日期：{{effectiveDate}}</span>
                    </Col>
                </Row>
                <Row class="detail-background-clor" style="line-height: 42px;">
                    <Col span='23'>
                        <span>备注：{{InputItemData.remarks}}</span>
                    </Col>
                </Row>
            </Form>
            <div slot="footer">
                <Button class='ivu-btn-save' @click="model5=false">关闭</Button>
            </div>
        </Modal>

    </Layout>
</template>

<script>
    import {Api} from '../../../../api/index.js'
    import {sessionStorage} from '../../../../common/cacheUtils.js';
    import cascaderDom from '../../../../components/cascader-dom.vue';

    export default {
        components: {cascaderDom},
        data() {
            return {
                certificateDate1:'',
                reviewDate1:'',
                switchFlag:false,
                certificateDate:['',''],
                reviewDate:['',''],
                brandList:[
                    {
                        name:'男',
                        value:'0',
                    },
                    {
                        name:'女',
                        value:'1',
                    }
                ],
                addItem:false,
                InputItemDate:{},
                model4:false,
                dataTable:[],
                tableHeight: '',loading: false,
                validityTerm:'',
                form1: {
                    agreementName: '',
                    contractorName: '',
                },
                pageSizeArray: [10, 20, 50],
                pagedata: {
                    total: 0,
                    pageSize: 10,
                    currentPage: 1,
                },
                model5:false,
                ruleCustom: {
                    driverName: [{
                        message: '  ',
                        required: true,
                        trigger: 'blue'
                    }],
                    license: [{
                        message: '  ',
                        required: true,
                        trigger: 'blur'
                    }],
                    brand: [{
                        message: '  ',
                        required: true,
                        trigger: 'blur'
                    }],
                    colour: [{
                        message: '  ',
                        required: true,
                        trigger: 'blur'
                    }],
                    engNum: [{
                        message: '  ',
                        required: true,
                        trigger: 'blur'
                    }],
                    belongOrgId: [{
                        message: '  ',
                        required: true,
                        trigger: 'change'
                    }],
                    workType: [{
                        message: '  ',
                        required: true,
                        trigger: 'blur'
                    }],
                    station: [{
                        message: '  ',
                        required: true,
                        trigger: 'blur'
                    }],
                    certificateNo: [{
                        message: '  ',
                        required: true,
                        trigger: 'blur'
                    }],
                    certificationAuthority: [{
                        message: '  ',
                        required: true,
                        trigger: 'blur'
                    }],
                    certcard: [{
                        message: '  ',
                        required: true,
                        trigger: 'blur'
                    }],
                    validityTerm: [{
                        validator: (rule, value, callback) => {
                            if (value == null || value == ''|| value == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    review: [{
                        message: '  ',
                        required: true,
                        trigger: 'blur'
                    }],
                    yearlyDate: [{
                        validator: (rule, value, callback) => {
                            if (value == null || value == ''|| value == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    certificateDate: [{
                        validator: (rule, value, callback) => {
                            if (value == null || value == ''|| value == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    reviewDate: [{
                        validator: (rule, value, callback) => {
                            if (value == null || value == ''|| value == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                },
                ruleCustom1: {
                    projectName: [{
                        message: '  ',
                        required: true,
                        trigger: 'blue'
                    }],
                    approvalDate: [{
                        validator: (rule, value, callback) => {
                            if (value == null || value == ''|| value == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    effectiveDate: [{
                        validator: (rule, value, callback) => {
                            if (value == null || value == ''|| value == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                },
                evaluateItem: [],
                columns3: [
                    {
                        type: 'index',
                        title: '序号',
                        width: 80,
                        align: 'center',
                    },
                    {
                        minWidth: 100,
                        title: '项目名称',
                        align: 'center',
                        key: 'projectName',
                    },
                    {
                        minWidth: 120,
                        title: '批准日期',
                        align: 'center',
                        key: 'approvalDate',
                        render: (h, params) => {
                            let approvalDate = new Date(params.row.approvalDate);
                            return h('span', approvalDate.getFullYear() + '-' + (approvalDate.getMonth() + 1) + '-' + approvalDate.getDate())
                        }
                    },
                    {
                        minWidth: 150,
                        title: '有效日期',
                        align: 'center',
                        key: 'effectiveDate',
                        render: (h, params) => {
                            let effectiveDate = new Date(params.row.effectiveDate);
                            return h('span', effectiveDate.getFullYear() + '-' + (effectiveDate.getMonth() + 1) + '-' + effectiveDate.getDate())
                        }
                    },
                    {
                        minWidth: 150,
                        title: '备注',
                        align: 'center',
						tooltip:true,
                        key: 'remarks',
                    },
                    {
                        title: '操作',
                        key: 'action',
                        fixed: 'right',
                        width: 200,
                        align: 'center',
                        render: (h, params) => {

                            return h('div', [
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                    },
                                    on: {
                                        click: () => {
                                            this.InputItemData = params.row;
                                            let effectiveDate = new Date(params.row.effectiveDate);
                                            this.effectiveDate = effectiveDate.getFullYear() + '-' + (effectiveDate.getMonth() + 1) + '-' + effectiveDate.getDate()

                                            let approvalDate = new Date(params.row.approvalDate);
                                            this.approvalDate = approvalDate.getFullYear() + '-' + (approvalDate.getMonth() + 1) + '-' + approvalDate.getDate()



                                            this.model5 = true;
                                        }
                                    }
                                }, '详情'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                    },
                                    on: {
                                        click: () => {
                                            this.InputItemData = params.row;
                                            this.model4 = true;
                                            this.addItem = false;
                                            this.index = params.index;
                                        }
                                    }
                                }, '修改'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'error',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                        color: 'red',
                                    },
                                    on: {
                                        click: () => {
                                            this.evaluateItem.splice(params.index,1);
                                        }
                                    }
                                }, '删除')
                            ]);
                        }
                    }
                ],
                index:null,
                currentUser: JSON.parse(sessionStorage('userId').get('userId')),
                columns1: [
                    {
                        type: 'index',
                        title: '序号',
                        width: 100,
						fixed: 'left',
                        align: 'center',
                    },

                    {
                        title: '姓名',
                        align: 'center',
						fixed: 'left',
                        key: 'driverName',
                        width: 150,
                    },
                    {
                        title: '性别',
                        align: 'center',
                        key: 'brand',
                        width: 100,
                        render: (h, params) => {
                            return h('div', [
                                (params.row.brand === '0'?'男':'女')
                            ]);
                        }
                    },
                    {
                        title: '身份证',
                        align: 'center',
                        key: 'colour',
                        width: 200,
                    },
                    {
                        title: '作业类型',
                        align: 'center',
                        key: 'workType',
                        width: 200,
                    },
                    {
                        title: '所属部门',
                        align: 'center',
                        key: 'belongOrgId',
                        width: 300,
                    },
                    {
                        title: '岗位',
                        align: 'center',
                        key: 'station',
                        width: 300,
                    },
                    {
                        title: '证书编号',
                        align: 'center',
                        key: 'certificateNo',
                        width: 300,
                    },
                    {
                        title: '发证机关',
                        align: 'center',
                        key: 'certificationAuthority',
                        width: 300,
                    },
                    {
                        title: '发证日期',
                        align: 'center',
                        key: 'certificateDate',
                        width: 150,
                        render: (h, params) => {
                            return h('div', [
                                (this.formatDate(new Date(params.row.certificateDate), 'yyyy-MM-dd'))
                            ]);
                        }
                    },
                    {
                        title: '有效期',
                        align: 'center',
                        key: 'validityTerm',
                        width: 150,
                        render: (h, params) => {
                            return h('div', [
                                (this.formatDate(new Date(params.row.validityTerm), 'yyyy-MM-dd'))
                            ]);

                        }
                    },

                    {
                        title: '复审日期',
                        align: 'center',
                        key: 'reviewDate',
                        width: 150,
                        render: (h, params) => {
                            return h('div', [
                                (this.formatDate(new Date(params.row.reviewDate), 'yyyy-MM-dd'))
                            ]);
                        }
                    },
                    {
                        title: '复审情况',
                        align: 'center',
                        key: 'review',
                        width: 150,

                    },
                    {
                        title: '操作',
                        key: 'action',
                        fixed: 'right',
                        width: 150,
                        align: 'center',
                        render: (h, params) => {
                            if(this.currentUser.loginId === this.Common.admin || this.currentUser.userId === params.row.createUsrId ){
                                return h('div', [
                                    h('A', {
                                        props: {
                                            type: 'primary',
                                            size: 'small'
                                        },
                                        style: {
                                            fontSize: '14px',
                                        },
                                        on: {
                                            click: () => {
                                                this.InputData = params.row;
                                                this.yearlyDate = this.formatDate(new Date(this.InputData.yearlyDate), 'yyyy-MM-dd');
                                                this.certificateDate1 = this.formatDate(new Date(this.InputData.certificateDate), 'yyyy-MM-dd');

                                                this.reviewDate1 = this.formatDate(new Date(this.InputData.reviewDate), 'yyyy-MM-dd');
                                                this.validityTerm = this.formatDate(new Date(this.InputData.validityTerm), 'yyyy-MM-dd');
                                                this.evaluateItem = params.row.saSemWorkerProjects;
                                                this.model3 = true;
                                            }
                                        }
                                    }, '详情'),
                                    h('Divider', {
                                        props: {
                                            type: 'vertical',
                                        }
                                    }, ''),
                                    h('A', {
                                        props: {
                                            type: 'primary',
                                            size: 'small'
                                        },
                                        style: {
                                            fontSize: '14px',

                                        },
                                        on: {
                                            click: () => {
                                                this.evaluateItem = params.row.saSemWorkerProjects;
                                                this.InputData = params.row;
                                                this.model1 = true;
                                                this.add = false;
                                            }
                                        }
                                    }, '修改')
                                ]);
                            }else{
                                return h('div', [
                                    h('A', {
                                        props: {
                                            type: 'primary',
                                            size: 'small'
                                        },
                                        style: {
                                            fontSize: '14px',
                                        },
                                        on: {
                                            click: () => {
                                                this.InputData = params.row;
                                                this.yearlyDate = this.formatDate(new Date(this.InputData.yearlyDate), 'yyyy-MM-dd');
                                                this.certificateDate1 = this.formatDate(new Date(this.InputData.certificateDate), 'yyyy-MM-dd');

                                                this.reviewDate1 = this.formatDate(new Date(this.InputData.reviewDate), 'yyyy-MM-dd');
                                                this.validityTerm = this.formatDate(new Date(this.InputData.validityTerm), 'yyyy-MM-dd');
                                                this.evaluateItem = params.row.saSemWorkerProjects;
                                                this.model3 = true;
                                            }
                                        }
                                    }, '详情'),
                                    h('Divider', {
                                        props: {
                                            type: 'vertical',
                                        }
                                    }, ''),
                                    h('A', {
                                        props: {type: 'primary', size: 'small'},
                                        style: {fontSize: '14px', color: '#c5c8ce'}
                                    }, '修改')
                                ]);
                            }

                        }
                    }
                ],
                updateParam:null,
                effectiveDate:'',
                approvalDate:'',
                add: false,
                model1: false,
                model3: false,
                contractTermDate1:'',
                evaluationPeriodDate1:'',
                yearlyDate:'',

                fileUrl: Api.interestedPartiesUserFile,
                InputData: {},
                buttonLoading: false,
                InputItemData:{},
                uploadList: [],

                pageModel2: {
                    total: 0,
                    pageSize: 10,
                    currentPage: 1,
                    contractorName: ''
                },
                contractor: [],
                model2: false,
            }
        },
        mounted() {
            this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 145;
            this.query()
        },
        computed: {
            columns10() {
                const columns = [...this.columns3];
                const columns10=[]
                columns.forEach(item=>{
                   if (item.title != '操作'){
                       columns10.push(item)
                   }
                });
                return columns10
            },
        },
        methods: {
            switchQuery(flag){
                this.switchFlag = flag;
                if(!this.switchFlag){
                    this.tableHeight = window.innerHeight - 220;
                }else{
                    this.tableHeight = window.innerHeight - 315;
                }
            },
            submitItem(name){
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        if (this.addItem){
                            this.evaluateItem.push(this.InputItemData);
                            this.model4 = false;
                        } else{
                            let index = this.index;
                            this.evaluateItem[index] = this.InputItemData;
                            this.model4 = false;
                        }

                    }else{
                        this.$Message.error('请填报完整!');
                    }
                })
            },
            addItemInfo(){
                this.addItem = true;
                this.InputItemData = {};
                this.model4 = true
            },
            danxuan(row, index) {
                this.InputData.contractorId = row.contractorId
                this.InputData.contractorName = row.contractorName
                this.model2 = false
                this.model1 = true
            },

            selectContractor() {
                this.model2 = true
                this.contractor = []
                let data = {
                    startPage: this.pageModel2.currentPage,
                    size: this.pageModel2.pageSize,
                    contractorName: this.pageModel2.contractorName
                }
                data = Object.assign(data);
                let url = Api.interestedPartiesAccountList
                this.$http.get(url, {params: data}).then((res) => {
                    this.contractor = res.data.data.data;
                    this.pageModel2.total = res.data.data.totalSize;
                }).catch(e => {
                    this.$Message.error("数据获取失败")
                })
            },
            setOrgId(data) {
                this.InputData.belongOrgId = data[data.length - 1];
            },
            setOrgName(data) {
                this.InputData.orgName = data;
            },


            downloadFile(perfId, file) {
                let url = this.fileUrl + '/file/' + file.id;
                this.$http.get(url, {
                    responseType: 'blob'      //告诉服务器我们需要的响应格式
                }).then((res) => {
                    const aLink = document.createElement("a");
                    let blob = new Blob([res.data], {
                        type: res.bodyBlob.type      //将会被放入到blob中的数组内容的MIME类型
                    });
                    aLink.href = URL.createObjectURL(blob)
                    aLink.download = file.fileName //标题
                    aLink.click()
                    document.body.appendChild(aLink)
                })
            },
            remove1(id) {
                let url = this.fileUrl + '/file/' + id;
                this.$http.delete(url).then((res) => {
                    this.getFiles()
                })
            },
            formatDate(date, fmt) {
                if (/(y+)/.test(fmt)) {
                    fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
                }
                let o = {
                    'M+': date.getMonth() + 1,
                    'd+': date.getDate(),
                    'h+': date.getHours(),
                    'm+': date.getMinutes(),
                    's+': date.getSeconds()
                };
                for (let k in o) {
                    if (new RegExp(`(${k})`).test(fmt)) {
                        let str = o[k] + '';
                        fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : this.padLeftZero(str));
                    }
                }
                return fmt;
            },
            padLeftZero(str) {
                return ('00' + str).substr(str.length);
            },
            beforeUpload(file) {
                let formData = new FormData();
                formData.append("files", file); // 文件对象
                let url = this.fileUrl + '/' + this.InputData.perfId + '/files/agreementFile'
                this.$http.post(url, formData).then((res) => {
                    if (res.data.result == "success") {
                        this.$Message.info("文件上传成功")
                        this.getFiles();
                    }
                })
                return false
            },
            getFiles() {
                let url = this.fileUrl + '/' + this.InputData.perfId + '/files/agreementFile'
                this.$http.get(url).then((res) => {
                    if (res.data.result == "success") {
                        this.uploadList = res.data.data
                    }
                })
            },

            onCancel() {
                this.InputData = {};
                this.evaluateItem = [];
                this.model1 = false;
                this.model3 = false;
                this.uploadList = [];
                this.query()
            },
            submit(name) {
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        this.buttonLoading=true
                        this.InputData.saSemWorkerProjects = this.evaluateItem;
                        if (this.add) {
                            let url = Api.saSemWorkerInfoSave;
                            this.InputData.createOrgId = sessionStorage('userId').getObject('userId').orgInfo.orgId;
                            this.InputData.createUsrId = sessionStorage('userId').getObject('userId').userId;
                            this.$http.post(url, this.InputData).then((res) => {
                                this.$Message.success('成功');
                                this.buttonLoading = false
                                this.model1 = false
                                this.query()
                            }).catch(e => {
                                this.$Message.error('请求失败');
                            })
                        } else {
                            let url = Api.saSemWorkerInfoUpdate;
                            this.InputData.createUsrId = sessionStorage('userId').getObject('userId').userId
                            this.InputData.updateOrgId = sessionStorage('userId').getObject('userId').orgInfo.orgId
                            this.$http.post(url, this.InputData).then((res) => {
                                this.$Message.success('成功');
                                this.buttonLoading = false
                                this.model1 = false
                                this.query()
                            }).catch(e => {
                                this.$Message.error('请求失败');
                            })
                        }
                    } else {
                        this.$Message.error('请填报完整!');
                    }
                })

            },

            deleteData(row) {
                let url = Api.saSemWorkerInfoDelete + '/' + row.driverId;
                this.$http.delete(url).then((res) => {
                    this.$Message.success('成功');
                    this.query()
                }).catch(e => {
                    this.$Message.error("数据获取失败")
                })
            },
            addInfo() {
                this.add = true;
                this.InputData = {};
                this.evaluateItem = [];
                this.model1 = true;
            },
            query() {
				this.loading = true ;
                let data = {
                    startPage: this.pagedata.currentPage,
                    size: this.pagedata.pageSize,
                    orgId: sessionStorage('userId').getObject('userId').companyId
                };
                if (this.certificateDate[0]!=""&&this.certificateDate[1]!=""){
                    this.form1.certificateStartDate =  this.formatDate(new Date(this.certificateDate[0]), 'yyyy-MM-dd');
                    this.form1.certificateEndDate = this.formatDate(new Date(this.certificateDate[1]), 'yyyy-MM-dd');
                }
                if (this.reviewDate[0]!=""&&this.reviewDate[1]!=""){
                    this.form1.reviewStartDate =  this.formatDate(new Date(this.reviewDate[0]), 'yyyy-MM-dd');
                    this.form1.reviewEndDate = this.formatDate(new Date(this.reviewDate[1]), 'yyyy-MM-dd');
                }
                data = Object.assign(data, JSON.parse(JSON.stringify(this.form1)));
                let url = Api.saSemWorkerInfoPending
                this.$http.get(url, {params: data}).then((res) => {
                    this.dataTable = res.data.data.data;
                    this.pagedata.total = res.data.data.totalSize;this.loading = false;
                }).catch(e => {
                    this.$Message.error("数据获取失败")
                })
            },
            reset() {
                this.form1 = {
                    agreementName: '',
                    contractorName: ''
                }
                this.certificateDate = ['',''];
                this.reviewDate = ['',''];
                this.pageModel2.currentPage = 1;
                this.pageModel2.contractorName = ''
				this.query();
            },
            pageChange1(pageNum) {
                this.pageModel2.currentPage = pageNum;
                this.query();
            },
            pageSizeChange1(pageSize) {
                this.pageModel2.pageSize = pageSize;
                this.query();
            },
            pageChange(pageNum) {
                this.pagedata.currentPage = pageNum;
                this.query();
            },
            pageSizeChange(pageSize) {
                this.pagedata.pageSize = pageSize;
                this.query();
            },
            get_uuid() {
                let s = [];
                let hexDigits = "0123456789abcdef";
                for (let i = 0; i < 36; i++) {
                    s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
                }
                s[14] = "4";
                s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
                s[8] = s[13] = s[18] = s[23] = "-";

                let uuid = s.join("");
                let reg = new RegExp("-", "g");
                let a = uuid.replace(reg, "");
                return a;
            },
			
			rowClassName(row,index){
				var date = this.formatDate(new Date(),'yyyy-MM-dd')
				if(row.reviewDate < date){
					return 'table-row-red';
				}
			},
        },
        watch:{
            "model1":function(qw,er){
                if(qw && this.model1){
                    setTimeout(()=>{
                        this.$refs.childOrg.setCurrentOrg();

                    },100)
                }else{
                    this.$refs.childOrg.setCurrentOrg();

                }
            },
        },
    }
</script>

<style scoped>
    @import '../../../../index.css';
	
	.ivu-table-tbody .table-row-red td{
	    background-color: #fedede !important;
	}
</style>